﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FlowBasis.Data
{
    /// <summary>
    /// IEntityPrimaryKeyService provides information about properties mapped
    /// to primary keys for entity objects.
    /// </summary>
    public interface IEntityPrimaryKeyService
    {
        /// <summary>
        /// This should try to retrieve the primary key property name for the given type. This should
        /// return null if there is no primary key property.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        IList<string> TryGetPrimaryKeyPropertyNames(Type type);

        /// <summary>
        /// This should return the value of the primary key for the given entity.
        /// </summary>
        /// <param name="entityInstance"></param>
        /// <returns></returns>
        object[] TryGetPrimaryKeyValues(object entityInstance);

        /// <summary>
        /// Assign primary key value to an entity instance if possible.
        /// </summary>
        /// <param name="entityInstance"></param>
        /// <param name="newPrimaryKeyValue"></param>
        bool AssignPrimaryKeyValues(object entityInstance, object[] newPrimaryKeyValues);
    }
}
